package com.mtf.multipledatasources.controller;

import com.alibaba.fastjson2.JSONObject;
import com.mtf.multipledatasources.dao.db1.KnSpace;
import com.mtf.multipledatasources.dao.db2.SysUser;
import com.mtf.multipledatasources.mapper.db1.KnSpaceMapper;
import com.mtf.multipledatasources.mapper.db2.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private KnSpaceMapper knSpaceMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    @GetMapping("/getData")
    public JSONObject getData() {
        List<KnSpace> knSpaces = knSpaceMapper.selectKnSpaceList(new KnSpace());
        List<SysUser> sysUsers = sysUserMapper.selectList();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("db1", knSpaces);
        jsonObject.put("db2", sysUsers);
        return jsonObject;
    }
}
